package com.example.bootdemo5.common;


/**
 * 封装消息体,统一返回标准
 */
public class CommonResult<T> {

    private boolean  success;
    private String message;
    private T   data;

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public CommonResult(boolean success, String message, T data) {
        this.success = success;
        this.message = message;
        this.data = data;
    }


    /**
     * 成功
     * @param message
     * @param data
     * @return
     */
    public  static  CommonResult SUCCESS(String message,Object data){
        return new CommonResult(true,message,data);
    }
    public  static  CommonResult SUCCESS(String message){
        return new CommonResult(true,message,null);
    }


    /**
     * 失败
     * @param message
     * @return
     */
    public  static  CommonResult FAILURE(String message){
        return new CommonResult(false,message,null);
    }


}
